package manong.mapper;

import manong.beans.User;
import manong.beans.UserQuery;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.session.RowBounds;

import java.util.List;
@Mapper
public interface UserMapper {
   
    long countByExample(UserQuery example);

    
    int deleteByExample(UserQuery example);

   
    @Delete({
        "delete from user",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    
    @Insert({
        "insert into user (username, `password`, ",
        "`role`, statu, mark)",
        "values (#{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, ",
        "#{role,jdbcType=VARCHAR}, #{statu,jdbcType=INTEGER}, #{mark,jdbcType=VARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(User record);

    
    int insertSelective(User record);

    List<User> selectByExampleWithRowbounds(UserQuery example, RowBounds rowBounds);

    
    User selectOneByExample(UserQuery example);

   
    List<User> selectByExample(UserQuery example);

  
    @Select({
        "select",
        "id, username, `password`, `role`, statu, mark",
        "from user",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("manong.mapper.UserMapper.BaseResultMap")
    User selectByPrimaryKey(Integer id);

    
    int updateByExampleSelective(@Param("record") User record, @Param("example") UserQuery example);

   
    int updateByExample(@Param("record") User record, @Param("example") UserQuery example);

   
    int updateByPrimaryKeySelective(User record);

   
    @Update({
        "update user",
        "set username = #{username,jdbcType=VARCHAR},",
          "`password` = #{password,jdbcType=VARCHAR},",
          "`role` = #{role,jdbcType=VARCHAR},",
          "statu = #{statu,jdbcType=INTEGER},",
          "mark = #{mark,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(User record);

    int insertOrUpdate(User record);

   
    int insertOrUpdateSelective(User record);

    
    int batchInsert(@Param("list") List<User> list);

    
    int batchInsertSelective(@Param("list") List<User> list, @Param("selective") User.Column ... selective);
}